<?php 
namespace Home\Controller;
use Think\Controller;
class IndexController extends BaseController{
	function index(){

        //用户所对应的购物车数量
		if ($_GET['id'] == 1) {
			session_destroy();
		}
		$entryOb=M('wares_entry');
		$arr=$entryOb->join('wares_type ON wares_type.id = wares_entry.wares_typeid')->where('wares_entry.state=0')->select();
		$this->assign('arr',$arr);
		$typeOb=M('wares_type');
		$Type=$typeOb->where('pid=0')->select();
		foreach ($Type as $key => $value) {
			 $Type[$key]['child']=array();
			 $TypeOne=$typeOb->where("pid={$value['id']}")->select();
			 foreach ($TypeOne as $ke => $val) {
			 		array_push($Type[$key]['child'],$val);
			 		 $TypeTwo=$typeOb->where("pid={$val['id']}")->select();
			 	    $Type[$key]['child'][$ke]['son'] = array();
			 foreach ($TypeTwo as $k => $v) {
			 		array_push($Type[$key]['child'][$ke]['son'],$v); 		
			 }
			 }
		}
		$this->assign('typeAll',$Type);
		$this->display();
	}

}